#include "uwbautofollow/dead_zone.h"

DeadZone::DeadZone()
{
    mZoneFlag = false;
}

DeadZone::DeadZone(float lowerValue, float higherValue)
{
    mZoneFlag = false;
    lowerLimit = lowerValue;
    higherLimit = higherValue;
}
DeadZone::~DeadZone() {}

void DeadZone::setLimit(float lowerValue, float higherValue)
{
    lowerLimit = lowerValue;
    higherLimit = higherValue;
}

bool DeadZone::getZoneByInput(float v)
{
    if (mZoneFlag)
    {
        if (v > higherLimit)
        {
            mZoneFlag = false;
        }
    }
    else
    {
        if (v < lowerLimit)
        {
            mZoneFlag = true;
        }
    }

    return mZoneFlag;
}
void DeadZone::reset()
{
    mZoneFlag = false;
}
